home *** CD-ROM | disk | FTP | other *** search
/ Merciful 2 / Merciful - Disc 2.iso / software / d / disksalviv.dms / disksalviv.adf / include / ds_stream.h
C/C++ Source or Header  |  1995-12-18  |  5KB  |  167 lines

  1. // ======================================================================
  2. //
  3. // D i s k S a l v  3  by Dave Haynie
  4. //
  5. // Archive Format Header File
  6. //
  7. // This file contains C language constructs that support the DiskSalv 
  8. // archive stream format.  The contents of this file are released to
  9. // the public domain. The DiskSalv archive format may be used in any
  10. // program without special license.
  11.  
  12. #ifndef DS_STREAM_H
  13. #define DS_STREAM_H
  14.  
  15. #include <exec/types.h>
  16. #include <dos/dos.h>
  17.  
  18. //======================================================================
  19. //
  20. // Local data types.
  21.  
  22. // All blocks are STBLOCKSIZE in length, although the structures shown
  23. // here don't bother to pad them out to full size in all cases.
  24.  
  25. #define STBLOCKSIZE    512
  26. #define STDATASIZE    (STBLOCKSIZE-sizeof(STHeader))
  27.  
  28. // This is the base of the streaming logic.  It is created by a call to
  29. // OpenStreaming() and destroyed by a call to CloseStreaming().
  30.  
  31. typedef struct {
  32.    BPTR            stream;        // DOS output stream.
  33.    LONG            filecount;    // Number of files in archive 
  34.    LONG            dircount;    // Number of directories in archive
  35.    LONG            linkcount;    // Number of links in archive
  36.    LONG            errcount;    // Number of recorded errors
  37.    LONG            objectcount;    // Total count of objects.
  38.    struct DateStamp    date;        // Date code for recovery set
  39.    char            *out;        // Output buffer
  40.    char            *dwbuf;        // Carryover buffer
  41.    LONG            dwalloc;    // Total buffer size
  42.    LONG            dwsize;        // Current buffer count
  43. } STBaseUnit;
  44.  
  45. // These are the handles for Disk, Directory, and File processing.  Each of
  46. // these handles must fit in a single block.
  47.  
  48. // Block type identifiers.  
  49.  
  50. #define ID_ROOT    ((LONG)(('R'<<24)|('O'<<16)|('O'<<8)|('T')))
  51. #define ID_UDIR    ((LONG)(('U'<<24)|('D'<<16)|('I'<<8)|('R')))
  52. #define ID_FILE    ((LONG)(('F'<<24)|('I'<<16)|('L'<<8)|('E')))
  53. #define ID_DATA    ((LONG)(('D'<<24)|('A'<<16)|('T'<<8)|('A')))
  54. #define ID_DLNK    ((LONG)(('D'<<24)|('L'<<16)|('N'<<8)|('K')))
  55. #define ID_FLNK    ((LONG)(('F'<<24)|('L'<<16)|('N'<<8)|('K')))
  56. #define ID_SLNK    ((LONG)(('S'<<24)|('L'<<16)|('N'<<8)|('K')))
  57. #define ID_ERRS    ((LONG)(('E'<<24)|('R'<<16)|('R'<<8)|('S')))
  58. #define ID_ENDA    ((LONG)(('E'<<24)|('N'<<16)|('D'<<8)|('A')))
  59.  
  60. // A "delete" block is a special block type. The contents are not meaningful.
  61. // This is written by a program to say "oh-by-the-way, that last file was bad, 
  62. // maybe you (the recovery program) would like to delete it".
  63.  
  64. #define SET_DEL    ((LONG)(('D'<<24)|('E'<<16)|('L'<<8)|('B')))
  65.  
  66. // This is the structure for the stream block header.  Stream blocks work much
  67. // like filesystem blocks.
  68.  
  69. typedef struct {
  70.    LONG         type;        // Block type.
  71.    LONG            size;        // Various size numbers go here.
  72.    LONG            count;        // Various block counts go here.
  73.    LONG            parent;        // The id number for the parent block.
  74.    LONG            id;        // The id number for the object.
  75.    LONG            checksum;    // A checksum code goes here.
  76. } STHeader;
  77.  
  78. // This structure manages standard file data.  Files, links, and directories 
  79. // each have one of these items.
  80.  
  81. typedef struct {
  82.    char         filename[32];    // File name 
  83.    LONG            protect;    // Protection field.
  84.    struct DateStamp    date;        // File date
  85.    char            filenote[92];    //   and Note
  86. } STBasics;
  87.  
  88. // This is the root block.  This block indicates the beginning of an
  89. // archive.
  90.  
  91. typedef struct {
  92.    STHeader         head;        // Standard header
  93.    char            name[32];    // Archive name
  94.    struct DateStamp    created,    // Original's creation date
  95.                         modified,    //   and modification date.
  96.                         date;        // Archive's creation date.
  97.    LONG            barcount;    // Count of file objects to use for restore.
  98. } STRoot;
  99.  
  100. // This is the end of archive block, which indicates the end of an
  101. // archive.
  102.  
  103. typedef struct {
  104.    STHeader        head;        // Standard header
  105.    STBaseUnit        base;        // Keep the base unit data for recovery reference.
  106. } STend;
  107.  
  108. // This is the file block.  This block indicates the start of a file.
  109.  
  110. typedef struct {
  111.    STHeader        head;        // Standard header
  112.    STBasics        body;        //  and contents
  113. } STFile;
  114.  
  115. // This is the data block.  This block is part of a file's contents.  The file made
  116. // up of a series of data blocks, terminated by the first non-data block.
  117.  
  118. typedef struct {
  119.    STHeader        head;        // Standard header
  120.    char            body[4];    //  and contents 
  121. } STData;
  122.  
  123. // This is the user directory block.  This block indicates a new directory.  A child
  124. // of the root device has a parent id of zero. 
  125.  
  126. typedef struct {
  127.    STHeader         head;        // Standard header
  128.    STBasics        body;        //  and contents
  129. } STDir;
  130.  
  131. // This is the hard link block.  This block indicates a link that should be created.
  132.  
  133. typedef struct {
  134.    STHeader        head;        // Standard header
  135.    STBasics        body;        //   and contents
  136.    LONG            link;        // File/Directory ID to link to.
  137.    LONG            chain;        // Link chain, if any.
  138.    
  139. } STHLink;
  140.  
  141. // This is the soft link block.  This block indicates a link that should be created.
  142.  
  143. typedef struct {
  144.    STHeader        head;        // Standard header
  145.    STBasics        body;        //   and contents
  146.    char            link[4];    // Link text
  147.    
  148. } STSLink;
  149.  
  150. // These are the special purpose error/comment blocks.  The actual meaning
  151. // of the block is dependent on the code it contains.
  152.  
  153. typedef struct {
  154.    STHeader        head;        // Standard header
  155.    LONG            code;        // Error type
  156.    LONG            link;        // Object referenced
  157. } STHErr;
  158.  
  159.  
  160. typedef struct {
  161.    STHeader        head;        // Standard header
  162.    LONG            code;        // Error type
  163.    char            link[4];    // Object referenced
  164. } STSErr;
  165.  
  166. #endif
  167.